import 'package:flutter/material.dart';
import 'package:flutter_snail/ui/style/snail_color.dart';
import 'package:flutter_snail/ui/style/snail_text_style.dart';

/// 文章
class ArticleItem extends StatelessWidget {
  const ArticleItem({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: SnailColor.white,
      padding: const EdgeInsets.all(15.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          _title,
          const SizedBox(height: 10),
          _content,
          const SizedBox(height: 20),
          const _BottomBar()
        ],
      ),
    );
  }

  /// 文章标题
  Widget get _title => const Text(
        '世事皆哭，唯有你甜，因为你人美还会说话，世事皆哭，唯有你甜，因为你人美还会说话',
        style: SnailTextStyle.black54_18m,
        maxLines: 1,
        overflow: TextOverflow.ellipsis,
      );

  /// 文章内容
  Widget get _content => Row(
        children: [
          const Expanded(
              child: Text(
            '淅淅沥沥的雨点拍打着窗沿，电视里播放纪录片《唯有香如故》,配乐加载着雨滴竟完全重'
            '合，给人一种深处桃源的感觉淅淅沥沥的雨点拍打着窗沿，电视里播放纪录片'
            '《唯有香如故》,配乐加载着雨滴竟完全重合，给人一种深处桃源的感觉',
            style: SnailTextStyle.greyCD_16,
            maxLines: 4,
            overflow: TextOverflow.ellipsis,
          )),
          const SizedBox(width: 30),
          Container(
            width: 100,
            height: 80,
            decoration: BoxDecoration(
                color: Colors.blue, borderRadius: BorderRadius.circular(5)),
          )
        ],
      );
}

/// 推荐来源
class _Sources extends StatelessWidget {
  const _Sources({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const Text('基于你的阅读兴趣推荐', style: SnailTextStyle.greyCD_16);
  }
}

class _BottomBar extends StatelessWidget {
  const _BottomBar({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [_author, _interactBtn],
    );
  }

  /// 作者
  Widget get _author => Row(
        children: [_avatar, const SizedBox(width: 10), _name],
      );

  /// 头像
  Widget get _avatar => const CircleAvatar(radius: 15);

  /// 作者名称
  Widget get _name => const Text('砚秋', style: SnailTextStyle.black54_12);

  /// 互动按钮
  Widget get _interactBtn => Row(
        children: [_comment, const SizedBox(width: 20), _praise],
      );

  /// 评论
  Widget get _comment => GestureDetector(
        child: Row(
          children: const [
            Icon(Icons.comment_bank_outlined, color: SnailColor.greyCD),
            SizedBox(width: 5),
            Text('8', style: SnailTextStyle.greyCD_12)
          ],
        ),
      );

  /// 点赞
  Widget get _praise => GestureDetector(
        child: Row(
          children: const [
            Icon(Icons.hail_outlined),
            SizedBox(width: 5),
            Text('48', style: SnailTextStyle.greyCD_12)
          ],
        ),
      );
}
